package topo.autosearch;

import com.zhtelecom.nms.framework.discover.ResourceSearchMothType;
import com.zhtelecom.nms.framework.discover.rstype.CPUType;
import com.zhtelecom.nms.framework.discover.rstype.DefaultSystemType;
import com.zhtelecom.nms.framework.discover.rstype.DeviceType;
import com.zhtelecom.nms.framework.discover.rstype.DisckType;
import com.zhtelecom.nms.framework.discover.rstype.GernalGroupSearchType;
import com.zhtelecom.nms.framework.discover.rstype.GernalTableSearchType;
import com.zhtelecom.nms.framework.discover.rstype.IPAddressType;
import com.zhtelecom.nms.framework.discover.rstype.InterfaceType;
import com.zhtelecom.nms.framework.discover.rstype.MemoryType;
import com.zhtelecom.nms.framework.discover.rstype.RouterType;
import com.zhtelecom.nms.framework.discover.rstype.SoftwareRunType;
import com.zhtelecom.nms.framework.discover.rstype.TCPServerType;
import java.util.List;
import java.util.Vector;

public class RsSearchMethodManager {
    static List<ResourceSearchMothType> list = new Vector();

    static {
        ResourceSearchMothType process = new DefaultSystemType();
        list.add(process);

        ResourceSearchMothType process = new TCPServerType();
        list.add(process);

        ResourceSearchMothType process = new InterfaceType();
        list.add(process);

        ResourceSearchMothType process = new MemoryType();
        list.add(process);

        ResourceSearchMothType process = new DisckType();
        list.add(process);

        ResourceSearchMothType process = new CPUType();
        list.add(process);

        ResourceSearchMothType process = new SoftwareRunType();
        list.add(process);

        ResourceSearchMothType process = new DeviceType();
        list.add(process);

        ResourceSearchMothType process = new IPAddressType();
        list.add(process);

        ResourceSearchMothType process = new RouterType();
        list.add(process);

        ResourceSearchMothType process = new GernalTableSearchType();
        list.add(process);

        ResourceSearchMothType process = new GernalGroupSearchType();
        list.add(process);
    }

    public static List<ResourceSearchMothType> getAllTypeSearchMoth() {
        return list;
    }

    public static List<String> getAllResourceSearchMothNames() {
        List names = new Vector();
        for (int i = 0; i < list.size(); i++) {
            ResourceSearchMothType process = (ResourceSearchMothType) list.get(i);
            names.add(process.getResourceSearchMoth());
        }
        return names;
    }

    public static String getClassNameByMothName(String mothName) {
        for (int i = 0; i < list.size(); i++) {
            ResourceSearchMothType process = (ResourceSearchMothType) list.get(i);
            if (process.getResourceSearchMoth().equals(mothName)) {
                return process.getClass().getName();
            }
        }

        return null;
    }

    public static ResourceSearchMothType getNewInstanceProcess(String className) {
        className = getClassNameByMothName(className);
        try {
            return (ResourceSearchMothType) Class.forName(className).newInstance();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        getAllResourceSearchMothNames();
    }
}